package com.aiyige.model;

import com.aiyige.utils.TimeUtils;
import com.chad.library.adapter.base.entity.MultiItemEntity;

import java.io.Serializable;

/**
 * 评论信息
 * Created by UQIANTU on 16/11/14.
 */

public class VideoEntity implements Serializable,MultiItemEntity {

    protected static final long serialVersionUID = 1L;
    private long id;
    private boolean isFree;
    private int stage;
    private long duration;
    private String title;
    private String url;
    private String cover;

    public int getPosition() {
        return position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    private int position;

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    private boolean selected;

    public VideoEntity() {

    }

    private VideoEntity(Builder builder) {
        setId(builder.id);
        isFree = builder.isFree;
        setStage(builder.stage);
        duration = builder.duration;
        setTitle(builder.title);
        setUrl(builder.url);
        setCover(builder.cover);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getId() {
        return id;
    }

    public void setIsFree(boolean isFree) {
        this.isFree = isFree;
    }

    public boolean getIsFree() {
        return isFree;
    }

    public void setStage(int stage) {
        this.stage = stage;
    }

    public int getStage() {
        return stage;
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    public long getDuration() {
        return duration;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUrl() {
        return url;
    }

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    @Override
    public int getItemType() {
        return 0;
    }

    public String getTime() {
        return TimeUtils.getDurationTimeForFavorite(duration);
    }

    public static final class Builder {
        private long id;
        private boolean isFree;
        private int stage;
        private long duration;
        private String title;
        private String url;
        private String cover;

        private Builder() {
        }

        public Builder id(long id) {
            this.id = id;
            return this;
        }

        public Builder isFree(boolean isFree) {
            this.isFree = isFree;
            return this;
        }

        public Builder stage(int stage) {
            this.stage = stage;
            return this;
        }

        public Builder duration(long duration) {
            this.duration = duration;
            return this;
        }

        public Builder title(String title) {
            this.title = title;
            return this;
        }

        public Builder url(String url) {
            this.url = url;
            return this;
        }

        public Builder cover(String cover) {
            this.cover = cover;
            return this;
        }

        public VideoEntity build() {
            return new VideoEntity(this);
        }
    }
}
